package com.toidep.entities;

import org.json.JSONObject;

import com.toidep.api.ParseJSON;
import com.toidep.config.Constants;

public class UpdateEntity {
	public final int FREE_TYPE_ALBUM = 1;
	public final int FREE_TYPE_VIDEO = 2;
	public final int FREE_TYPE_NEWS  = 3;
	public final int FREE_TYPE_STORY = 4;
	public final int FREE_TYPE_EVENT = 5;
	
	private VideoEntity videoEntity = null;
	private AlbumEntity albumEntity = null;
	private ArticleEntity articleEntity = null;
	private int freeType = 0;
	
	public void setInfo(JSONObject jsonObject) {
		if (jsonObject != null) {
			String type = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_IS_TYPE);
			if (type.equals("album")) {
				freeType = FREE_TYPE_ALBUM;
				albumEntity = new AlbumEntity();
				albumEntity.setInfo(jsonObject);
			} else if (type.equals("video")) {
				freeType = FREE_TYPE_VIDEO;
				videoEntity = new VideoEntity();
				videoEntity.setInfo(jsonObject);
			} else if (type.equals("news")) {
				freeType = FREE_TYPE_NEWS;
				articleEntity = new ArticleEntity();
				articleEntity.setInfo(jsonObject);
			} else if (type.equals("story")) {
				freeType = FREE_TYPE_STORY;
				articleEntity = new ArticleEntity();
				articleEntity.setInfo(jsonObject);
			} else if (type.equals("event")) {
				freeType = FREE_TYPE_EVENT;
				articleEntity = new ArticleEntity();
				articleEntity.setInfo(jsonObject);
			}
		}
	}

	/**
	 * @return the videoEntity
	 */
	public VideoEntity getVideoEntity() {
		return videoEntity;
	}

	/**
	 * @param videoEntity the videoEntity to set
	 */
	public void setVideoEntity(VideoEntity videoEntity) {
		this.videoEntity = videoEntity;
	}

	/**
	 * @return the albumEntity
	 */
	public AlbumEntity getAlbumEntity() {
		return albumEntity;
	}

	/**
	 * @param albumEntity the albumEntity to set
	 */
	public void setAlbumEntity(AlbumEntity albumEntity) {
		this.albumEntity = albumEntity;
	}

	/**
	 * @return the freeType
	 */
	public int getFreeType() {
		return freeType;
	}

	/**
	 * @param freeType the freeType to set
	 */
	public void setFreeType(int freeType) {
		this.freeType = freeType;
	}

	/**
	 * @return the articleEntity
	 */
	public ArticleEntity getArticleEntity() {
		return articleEntity;
	}

	/**
	 * @param articleEntity the articleEntity to set
	 */
	public void setArticleEntity(ArticleEntity articleEntity) {
		this.articleEntity = articleEntity;
	}
}
